<template>
    <div class="h-100">
        <div class="h-100 flex row-center col-center" v-if="loading">
            <van-loading/>
        </div>

        <div class="h-100 flex row-center col-center f14" v-if="!loading && (listData.length === 0)">暂无安全生产基本信息</div>
        <van-cell v-for="(item, index) of listData" :key="index" :title="item.name" :value="item.value"></van-cell>
    </div>
</template>

<script>
    import cy from '../mixins/cy';

    export default {
        mixins: [cy],
        props: {
            // 企业 ID
            id: {
                type: String,
                default: ''
            }
        },
        data() {
            return {
                // 数据源
                listData: [],
                // 其他
                // 是否正在加载：true-是；false-否
                loading: false
            }
        },
        mounted() {
            this.loading = true;

            this.$$getEnBaseSafeProDataDetail(this.id).then(data => {
                let dataVo = data.content[0];
                let enterprise_scale = ''
                if (dataVo.enterprise_scale == '1') {
                    enterprise_scale = '微型'
                } else if (dataVo.enterprise_scale == '2') {
                    enterprise_scale = '小型'
                } else if (dataVo.enterprise_scale == '3') {
                    enterprise_scale = '中型'
                } else if (dataVo.enterprise_scale == '4') {
                    enterprise_scale = '大型'
                }

                // 参照安全云APP
                this.listData = [
                    {
                        name: '主要负责人',
                        value: dataVo.main
                    },
                    {
                        name: '主要负责人固定电话号码',
                        value: dataVo.main_fix
                    },
                    {
                        name: '主要负责人移动电话号码	',
                        value: dataVo.main_mobile
                    },
                    {
                        name: '主要负责人电子邮箱',
                        value: dataVo.main_email
                    },
                    {
                        name: '安全负责人',
                        value: dataVo.safety
                    },
                    {
                        name: '安全负责人固定电话号码',
                        value: dataVo.safety_fix
                    },
                    {
                        name: '安全负责人移动电话号码',
                        value: dataVo.safety_mobile
                    },
                    {
                        name: '安全负责人电子邮箱',
                        value: dataVo.safety_email
                    },
                    {
                        name: '安全机构设置情况',
                        value: dataVo.safety_mechanism == '0' ? '有' : '无'
                    },
                    {
                        name: '从业人员数量',
                        value: dataVo.employees_number
                    },
                    {
                        name: '特种作业人员数量',
                        value: dataVo.special_number
                    },
                    {
                        name: '专职安全生产管理人员数',
                        value: dataVo.manager_number
                    },
                    {
                        name: '专职应急管理人员数',
                        value: dataVo.emergency_number
                    },
                    {
                        name: '注册安全工程师人员数',
                        value: dataVo.engineer_number
                    },
                    {
                        name: '规模情况',
                        value: dataVo.enterprise_scale
                    },
                    {
                        name: '企业规模',
                        value: enterprise_scale
                    },
                    {
                        name: '安全监管监察机构',
                        value: dataVo.safety_regulator_name
                    },
                    {
                        name: '生产/经营地址',
                        value: dataVo.business_address
                    }
                ];

                this.loading = false;
            }).catch(e => {
                console.error(e);

                this.loading = false;
            });
        }
    }
</script>
